﻿using System.Collections.Generic;
using OL = Microsoft.Office.Interop.Outlook;

namespace uTILLIty.Outlook.FlexFileAddIn
{
	public class ExchangeStoreTypeComparer : IComparer<OL.OlExchangeStoreType>
	{
		#region Implementation of IComparer<in OlExchangeStoreType>

		/// <summary>
		/// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
		/// </summary>
		/// <returns>
		/// A signed integer that indicates the relative values of <paramref name="x"/> and <paramref name="y"/>, as shown in the following table.Value Meaning Less than zero<paramref name="x"/> is less than <paramref name="y"/>.Zero<paramref name="x"/> equals <paramref name="y"/>.Greater than zero<paramref name="x"/> is greater than <paramref name="y"/>.
		/// </returns>
		/// <param name="x">The first object to compare.</param><param name="y">The second object to compare.</param>
		public int Compare(OL.OlExchangeStoreType x, OL.OlExchangeStoreType y)
		{
			int intX = GetValue(x);
			int intY = GetValue(y);

			return intX.CompareTo(intY);
		}

		protected virtual int GetValue(OL.OlExchangeStoreType olExchangeStoreType)
		{
			switch (olExchangeStoreType)
			{
				case OL.OlExchangeStoreType.olPrimaryExchangeMailbox:
					return 10;
				case OL.OlExchangeStoreType.olExchangeMailbox:
					return 30;
				case OL.OlExchangeStoreType.olExchangePublicFolder:
					return 100;
				case OL.OlExchangeStoreType.olNotExchange:
					return 150;
				case OL.OlExchangeStoreType.olAdditionalExchangeMailbox:
					return 20;
				default:
					return 200;
			}
		}

		#endregion
	}
}